import { Component, OnInit, Inject } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';

import { BlogService } from '../blog.service';

@Component({
  selector: 'app-about-me',
  templateUrl: './about-me.component.html',
  styleUrls: ['./about-me.component.scss']
})
export class AboutMeComponent implements OnInit {
  content: string;
  isOnLoading = true;

  constructor(
    private blogService: BlogService,
    public dialogRef: MatDialogRef<AboutMeComponent>,
    @Inject(MAT_DIALOG_DATA) public data: any
  ) { }

  ngOnInit() {
    this.blogService.getAbout()
      .subscribe(about => {
        this.isOnLoading = true;
        this.blogService.markedContent(about)
        .subscribe(mdContent => {
          this.content = mdContent;
          this.isOnLoading = false;
        });
      });
  }

  onNoClick(): void {
    this.dialogRef.close();
  }
}
